public class Counter {

	private Count_itf cpt;

	public static void main(String args[]) {

		Client.init();

		Count_itf c = (Count_itf)Client.lookup("CPT");
		if(c == null) {
			c = (Count_itf)Client.create(new Count());
			Client.register("CPT", c);
		}
		new Counter(c);
		

		//Client.close();
		//System.exit(0);
	}

	public Counter(Count_itf c) {
		this.cpt = c;
		for(int i = 0; i < 1000 ; i++) {
			this.cpt.lock_write();
			this.cpt.inc();
			if(i == 0 || i == 999) {
				System.out.println("Current value : " + cpt.read());
			} else if(i == 2) {
				System.out.println("Current...");
			}
			this.cpt.unlock();
		}
		System.out.close();
		System.err.close();
	}

}
